package cn.e4j.modular.api.service;

import cn.e4j.core.dto.impl.Dto;
import cn.e4j.modular.api.mapper.FhpsMapper;
import cn.e4j.modular.crm.entity.GwcuT;
import cn.e4j.modular.crm.entity.MmraT;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


@Service
public class FhpsService{

    @Autowired
    FhpsMapper fhpsMapper;


    /**
     * 获取承运公司
     * @param inDto
     * @return
     */
    @Transactional(readOnly = true)
    public List<Dto> getCompany(Dto inDto) {

        return fhpsMapper.getCompany(inDto);
    }

    /**
     * 获取已运输数量
     * @param inDto
     * @return
     */
    @Transactional(readOnly = true)
    public Integer getAlready(Dto inDto) {
        return fhpsMapper.getAlready(inDto);
    }

    /**
     * 获取总订单数
     * @param inDto
     * @return
     */
    @Transactional(readOnly = true)
    public Dto getTotal(Dto inDto) {
        return fhpsMapper.getTotal(inDto);
    }

    /**
     * 获取明细
     * @param inDto
     * @return
     */
    @Transactional(readOnly = true)
    public List<Dto> getDetail(Dto inDto) {
        return fhpsMapper.getDetail(inDto);
    }

    @Transactional(readOnly = true)
    public Integer getMaxSeq(Dto inDto) {
        return fhpsMapper.getMaxSeq(inDto);
    }

    @Transactional
    public void save(List<GwcuT> gwcuts, List<MmraT> mmra_tPOS) {
        gwcuts.forEach(gwcut->{
            gwcut.insert();
        });

        mmra_tPOS.forEach(mmra->{
            mmra.insert();
        });
    }

    @Transactional(readOnly = true)
    public Integer validateProductNoInKC(Dto inDto) {
        return fhpsMapper.validateProductNoInKC(inDto);
    }

    @Transactional(readOnly = true)
    public Integer ValidateOrderNoInOrder(Dto inDto) {
        return fhpsMapper.ValidateOrderNoInOrder(inDto);
    }

    @Transactional(readOnly = true)
    public Integer ValidateProductNoInOrder(Dto inDto) {
        return fhpsMapper.ValidateProductNoInOrder(inDto);
    }

    @Transactional(readOnly = true)
    public Integer ValidateProductInMmra(Dto inDto) {
        return fhpsMapper.ValidateProductInMmra(inDto);
    }

    @Transactional(readOnly = true)
    public List<Dto> getOrderList(Dto queryDto) {
        return fhpsMapper.getOrderList(queryDto);
    }
}
